import React from 'react';
import { Table, Tag } from "antd";
import { changeFormat } from '@/utils/format';

export default function AttentTable({ title, data }) {
    const columns = [
        {
            title: '姓名',
            dataIndex: 'staffName',
            render: (value) => {
                return value.userName;
            }
        },
        {
            title: '考勤时间',
            dataIndex: 'createTime',
            render: (time) => {
                return changeFormat(time, 'YYYY-MM-DD HH:mm:ss')
            }
        },
        {
            title: '考勤类型',
            dataIndex: 'attendanceType',
            render: (attendanceType) => {
                return <Tag color='red'>{attendanceType === 3 ? "迟到" : "早退"}</Tag>
            }
        },
        {
            title: "部门",
            dataIndex: "staffName",
            render(value) {
                console.log(value)
                return <Tag >{value.department ? value.department?.departmentName : "暂无部门信息"}</Tag>
            }
        }
    ];
    return (
        <div className='attent-list-item' >
            <div className="list-item-title">{title}</div>
            <div className="list-item-container">
                <Table
                    dataSource={data}
                    pagination={false}
                    columns={columns}
                    rowKey={(value) => value._id}
                ></Table>

            </div>
        </div>
    )
}
